<?php
header("Content-Type: text/html; charset=utf-8");
require_once '../smarty/Smarty.class.php';
require_once '../lib/query_railway.php';
require_once '../lib/base.php';
$user=$_SESSION["RU"];
if(!$user)header("Location:../user/login.php");

if($_POST["act"]=="modify") {
	$old_password=urldecode($_POST["opw"]);
	$new_password=urldecode($_POST["npw"]);
	$nrpw=urldecode($_POST["nrpw"]);
	if($new_password!=$nrpw){echo "2次新密码输入不一致，请重新输入新密码！";exit;}
	$check_user=QR::check_exist($tb_user,"id=".$user["id"]." and ps='".$old_password."'");
	if(!$check_user){echo "原密码错误！";exit;}
	
	$_set="set ps='".$new_password."' where id=".$user["id"];
	$op=QR::update_data($tb_user,$_set);
	if($op>0)echo "100" ;else echo "未知错误，密码未修改！";
	exit;
}
$smarty = new Smarty;
$smarty->assign("user",$user);
$smarty->display('user_password.tpl');

?>